import string

with open('input.txt') as file:
    result = 0
    
    for group in file.read().split('\n\n'):
        answers = set(string.ascii_lowercase)

        for person in group.split():
            answers &= set(person)

        result += len(answers)

print(result)